package com.hdd.art.biz.painting.controller;

import com.hdd.art.biz.painting.dto.PaintingMediaDto;
import com.hdd.art.biz.painting.dto.PaintingMediaInfoDto;
import com.hdd.art.biz.painting.entity.PaintingMedia;
import com.hdd.art.biz.painting.service.PaintingMediaService;
import com.hdd.art.dto.AppResponse;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

@RestController
@RequestMapping("/painting/voice")
@Api(value = "作品模块-语音",tags = {"作品模块-语音"})
public class PaintingWorksVoiceController {

    @Autowired
    private PaintingMediaService mediaService;

    @PostMapping("/addVoice")
    @ApiOperation(value = "音频添加" ,notes = "")
    public AppResponse addVoice(@Valid @RequestBody PaintingMediaInfoDto mediaDto ){
        AppResponse response = new AppResponse();
        PaintingMedia media = new PaintingMedia();
        BeanUtils.copyProperties(mediaDto,media);
        media.setStatus("T");
        media.setIsUse("F");
        mediaService.addVoice(media);
        return response;
    }


    @PostMapping("/delVoice")
    @ApiOperation(value = "音频删除" ,notes = "")
    public AppResponse delVoice(@Valid @RequestBody PaintingMediaDto memberDo ){
        AppResponse response = new AppResponse();
        mediaService.delPaintingMedia(memberDo.getId());
        return response;
    }


    @PostMapping("/voiceList")
    @ApiOperation(value = "音频列表" ,notes = "")
    public AppResponse voiceList(@Valid @RequestBody PaintingMediaDto mediaDto ){
        AppResponse response = new AppResponse();
        response.setItems(mediaService.mediaList(mediaDto.getWorkId()));
        return response;
    }

    @PostMapping("/voiceUse")
    @ApiOperation(value = "使用该录音" ,notes = "")
    public AppResponse voiceUse(@Valid @RequestBody PaintingMediaDto mediaDto ){
        AppResponse response = new AppResponse();
        mediaService.mediaUse(mediaDto.getWorkId(),mediaDto.getId());
        return response;
    }
}
